<?php
/**
 * 信息提示
 * @param type $url
 * @param type $show
 */
function massage($url, $show = '操作成功！') {
    if ($this->isAjax()) {
        $msg = <<<STR
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>' . $show . '</title>
<style type="text/css" media="all">
	html,body{height:100%; margin:0; padding:0; font:13px/1.5 Verdana, Arial, FreeSans, sans-serif; background:#3F4458;}
	#content{clear:both; width:300px; height:130px; margin:-80px 0 0 -150px; position:absolute; top:45%; left:45%; background-color:#EBF2FA; border:8px solid #CBD5E1; padding:14px 50px;}
	a{color:#2A609F;}
</style>
</head>
<body>
	<div id="content">
		<h3>' . $show . '</h3>
		<p>2秒后返回指定页面！</p>
		<p>如果浏览器无法跳转，<a href="' . $url . '" target="_top">请点击此处</a></p>
		<script>setTimeout("window.location.href =' . "'" . $url . "'" . ';", 2000);</script>
	</div>
</body>
</html>
STR;
    } else {
        $msg = $show;
    }
    echo $msg;
    exit();
}

/**
 * 是否为AJAX响应
 * @return boolean
 */
function isAjax(){
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || isset($_GET['ajax'])) {
        return TRUE;
    } else {
        return FALSE;
    }
}
function DeleteHtml($str) {
    $str = str_replace(array("/r/n", "/r", "/n"), "", $str);
    return trim($str);
}
function gtu($str) {
    return mb_convert_encoding($str, "UTF-8", "GB2312");
}
function utg($str) {
    return mb_convert_encoding($str, "GB2312", "UTF-8");
}
function utgb($str) {
    return mb_convert_encoding($str, "GBK", "UTF-8");
}
function gbtu($str) {
    return mb_convert_encoding($str, "UTF-8", "GBK");
}
Function ClearHtml($content) {  
   $content = preg_replace("/<li[^>]*>/i", "", $content);
   $content = preg_replace("/<\/li>/i", "", $content);
   $content = preg_replace("/<font[^>]*>/i", "", $content);
   $content = preg_replace("/<\/font>/i", "", $content);   
   $content = preg_replace("/<a[^>]*>/i", "", $content);  
   $content = preg_replace("/<\/a>/i", "", $content);   
   $content = preg_replace("/<div[^>]*>/i", "", $content);  
   $content = preg_replace("/<\/div>/i", "", $content);      
   $content = preg_replace("/<!--[^>]*-->/i", "", $content);//注释内容
   $content = preg_replace("/style=.+?['|\"]/i",'',$content);//去除样式  
   $content = preg_replace("/class=.+?['|\"]/i",'',$content);//去除样式  
   $content = preg_replace("/id=.+?['|\"]/i",'',$content);//去除样式     
   $content = preg_replace("/lang=.+?['|\"]/i",'',$content);//去除样式      
   $content = preg_replace("/width=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/height=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/border=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/face=.+?['|\"]/i",'',$content);//去除样式   
   $content = preg_replace("/face=.+?['|\"]/",'',$content);//去除样式只允许小写正则匹配没有带 i 参数
   return $content;
}
?>